package Command;

import Command.commandInterfacesImpl.*;
import Command.commons.interfacesImpl.CeilingFan;
import Command.commons.interfacesImpl.Light;
import Command.commons.interfacesImpl.Stereo;
import Command.control.RemoteControl;
import Command.control.SimpleRemoteControl;
import org.junit.Test;

/**
 * @Author: pengzx
 * @Description:
 * @Date: 10:33 2017/9/12
 * @Modified by: 1.0
 */
public class Demo {
    @Test
   public void test(){
        SimpleRemoteControl simpleRemoteControl = new SimpleRemoteControl();//调用者
        Stereo stereo = new Stereo("Live");//接收者
        StereoOnWithCDCommand stereoOnWithCDCommand = new StereoOnWithCDCommand(stereo);//创建命令

        simpleRemoteControl.setCommand(stereoOnWithCDCommand);//传输命令
        simpleRemoteControl.buttonWasPressed();//调用命令
   }

   @Test
   public void test2(){

       RemoteControl remoteControl = new RemoteControl();
       /**
        * 创建所有接收者
        */
       Light roomLight = new Light("Room Light");
       Light kitchenLight = new Light("kitchen Light");
       Stereo LivingRoomStereo = new Stereo("Living Room");

       /**
        * 创建所有命令对象
        */
       LightOnCommand roomLightOn = new LightOnCommand(roomLight);
       LightOffCommand roomlLightOff = new LightOffCommand(roomLight);
       StereoOnWithCDCommand stereoOnWithCDCommand = new StereoOnWithCDCommand(LivingRoomStereo);
       StereoOffCommand stereoOffCommand = new StereoOffCommand(LivingRoomStereo);

       /**
        * 加入命令集中
        */
       remoteControl.setCommands(0,roomLightOn,roomlLightOff);
       remoteControl.setCommands(1,stereoOnWithCDCommand,stereoOffCommand);

       System.out.println(remoteControl);

       remoteControl.OffButtonWasPressed(0);
       remoteControl.undoButtonWasPressed();
   }
   @Test
   public void test3(){
       RemoteControl remoteControl = new RemoteControl();

       CeilingFan ceilingFan = new CeilingFan("Living Room");

       CeilingFanHighCommadn ceilingFanHighCommadn = new CeilingFanHighCommadn(ceilingFan);
       CeilingFanLowCommand ceilingFanLowCommand = new CeilingFanLowCommand(ceilingFan);
       CeilingFanOffCommand ceilingFanOffCommand = new CeilingFanOffCommand(ceilingFan);

       remoteControl.setCommands(0,ceilingFanHighCommadn,ceilingFanOffCommand);

       remoteControl.OnButtonWasPressed(0);
       remoteControl.OffButtonWasPressed(0);
       System.out.println(remoteControl);
       remoteControl.undoButtonWasPressed();

   }

   @Test
   public void test4(){
       int a = 1010;
       int b = 1101;

       System.out.println(a&b);
   }
}
